// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 返回训练文件名称，删除模型 DELETE /Train/delete */
export async function deleteTrainUsingDELETE(
  body: API.trainFile,
  options?: { [key: string]: any },
) {
  return request<string>('/Train/delete', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 返回所有训练文件的所有名称 GET /Train/Trainlist */
export async function selectTrainlistUsingGET(options?: { [key: string]: any }) {
  return request<API.trainFile[]>('/Train/Trainlist', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 上传训练文件 POST /Train/Upload */
export async function TestUploadUsingPOST1(body: string, options?: { [key: string]: any }) {
  const formData = new FormData();

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      formData.append(
        ele,
        typeof item === 'object' && !(item instanceof File) ? JSON.stringify(item) : item,
      );
    }
  });

  return request<string>('/Train/Upload', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}
